<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core">
    <h:head>
        <title>Facelet Title</title>
    </h:head>
    <h:body>
        <h:form>
            <table>
                <tr>
                    <td colspan="3"><h1>Validate</h1>
                    </td>
                </tr>
                <tr>
                    <td>Enter your name :</td>
                    <td>
                        <h:inputText id="txtUsername" value="#{bean.username}">
                            <f:validateLength minimum="5" maximum="20"/>
                        </h:inputText>
                    </td>
                    <td>
                        <h:message style="color: red" for="txtUsername"/>
                    </td>
                </tr>
                <tr>
                    <td>Enter your Age :</td>
                    <td>
                        <h:inputText id="txtAge" value="#{bean.age}">
                            <f:validateLongRange minimum="18" maximum="120"/>
                        </h:inputText>
                    </td>
                    <td>
                        <h:message style="color: red" for="txtAge"/>
                    </td>
                </tr>
                <tr>
                    <td>Enter your email :</td>

                    <td>
                        <h:inputText value="#{bean.email}" id="txtEmail">
                            <f:validator validatorId="Emailvalidator"/></h:inputText>
                    </td>
                    <td>
                        <h:message style="color: red" for="txtEmail"/>
                    </td>
                </tr>
                <tr>
                    <td></td>
                    <td colspan="2">
                        <h:commandButton value="Check Validator" action="#{bean.checkEmail}"/>
                    </td>
                </tr>
            </table>
        </h:form>
    </h:body>
</html>

